package br.com.hotel68;

import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;

import br.com.hotel68.dao.BaseDAO;
import br.com.hotel68.model.Client;
import br.com.hotel68.model.Room;
import br.com.hotel68.model.RoomType;


public class Hotel68BusinessFacade {

	private Properties config;

	public Hotel68BusinessFacade(Properties properties) {
		this.config = properties;
		
		// inicializacao da conexao ao banco de dados, se necessario
		//BaseDAO.init();
	}
	
	public String version() {
		return config.getProperty("system.version");
	}


	// Metodos de negocio, devem ser as operacoes que sao realizadas pelo usuario, como consultar reservas,
	// listar opcoes de quartos, etc., conforme especificado em documento de requisitos (GoogleDocs)
	// Por enquanto sao exemplos/testes
	
	public Collection<Room> findRooms() {
		return BaseDAO.findAll(Room.class);
	}

	public Collection<Client> findClients() {
		return BaseDAO.findAll(Client.class);
	}
	
	public Client findClientById(Integer id) {
		return BaseDAO.findById(Client.class, id);
	}

	public Collection<RoomType> findRoomTypes() {
		Collection<RoomType> types = Arrays.asList(RoomType.values());
		return types;
	}
	
	
	public boolean saveClient(String clientName) throws Exception {
		Client client = new Client();
		client.setName(clientName);
		
		return true;
	}
	
}
